var Options = 
{
	Domain: {}, 
	Blocking: {}, 
};

//=================Properties definition begins===========================
(function()
{

/*
 * Domain:
 *     Force ( boolean ) [true]
 *     AutoDetect ( boolean ) [true]
 *     Current ( string ) ["bbs.stuhome.net"]
 */
var localStorage_Domain_Force = "Domain.Force";
Object.defineProperty(Options.Domain, "Force", 
{
	get: (function(){
		return localStorage[localStorage_Domain_Force] != "false";
	   	//force single domain by default
	}), 
	set: (function(newValue){
		var value = newValue ? true : false;
		var old = localStorage[localStorage_Domain_Force];
		if(old == value)
			return;
		localStorage[localStorage_Domain_Force] = value;
		Options.Domain.onChanged&&Options.Domain.onChanged({
			"name": "Force", 
			"oldValue": old, 
			"newValue": value
		});
	}), 
});

var localStorage_Domain_AutoDetect = "Domain.AutoDetect";
Object.defineProperty(Options.Domain, "AutoDetect", 
{
	get: (function(){
		return localStorage[localStorage_Domain_AutoDetect] != "false";
		//auto detect domain by default
	}), 
	set: (function(newValue){
		var value = newValue ? true : false;
		localStorage[localStorage_Domain_AutoDetect] = value;
		Options.Domain.onChanged&&Options.Domain.onChanged();
	}), 
});

var localStorage_Domain_Current = "Domain.Current";
Object.defineProperty(Options.Domain, "Current", 
{
	get: (function(){
		return localStorage[localStorage_Domain_Current] || 
			"bbs.stuhome.net"; //internal domain by default
	}), 
	set: (function(newValue){
		localStorage[localStorage_Domain_Current] = newValue;
		Options.Domain.onChanged&&Options.Domain.onChanged();
	}), 
});

/*
 * Blocking:
 *     PostsByUsers ( array of string )
 *     SignaturesOfUsers ( array of string )
 *     PhotosOfUsers ( array of string )
 *     ImagesInPostsByUsers ( array of string )
 */
var localStorage_Blocking_PostsByUsers = "Blocking.PostsByUsers";
Object.defineProperty(Options.Blocking, "PostsByUsers", 
{
	get: (function(){
		var v = localStorage[localStorage_Blocking_PostsByUsers];
		return v ? JSON.parse(v) : []; //blocking nothing by default
	}), 
	set: (function(newValue){
		localStorage[localStorage_Blocking_PostsByUsers] = 
			JSON.stringify(newValue);
	}), 
});

var localStorage_Blocking_SignaturesOfUsers = "Blocking.SignaturesOfUsers";
Object.defineProperty(Options.Blocking, "SignaturesOfUsers", 
{
	get: (function(){
		var v = localStorage[localStorage_Blocking_SignaturesOfUsers];
		return v ? JSON.parse(v) : []; //blocking nothing by default
	}), 
	set: (function(newValue){
		localStorage[localStorage_Blocking_SignaturesOfUsers] = 
			JSON.stringify(newValue);
	}), 
});

var localStorage_Blocking_PhotosOfUsers = "Blocking.PhotosOfUsers";
Object.defineProperty(Options.Blocking, "PhotosOfUsers", 
{
	get: (function(){
		var v = localStorage[localStorage_Blocking_PhotosOfUsers];
		return v ? JSON.parse(v) : []; //blocking nothing by default
	}), 
	set: (function(newValue){
		localStorage[localStorage_Blocking_PhotosOfUsers] = 
			JSON.stringify(newValue);
	}), 
});

var localStorage_Blocking_ImagesInPostsByUsers = 
	"Blocking.ImagesInPostsByUsers";
Object.defineProperty(Options.Blocking, "ImagesInPostsByUsers", 
{
	get: (function(){
		var v = localStorage[localStorage_Blocking_ImagesInPostsByUsers];
		return v ? JSON.parse(v) : []; //blocking nothing by default
	}), 
	set: (function(newValue){
		localStorage[localStorage_Blocking_ImagesInPostsByUsers] = 
			JSON.stringify(newValue);
	}), 
});


})();

